package com.zrrd.spring_02;

import com.zrrd.spring_02.mapper.TeaDao;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

/**
 * @author WanJl
 * @version 1.0
 * @title Main02
 * @description
 * @create 2024/10/25
 */
public class Main02 {
    public static void main(String[] args) {
        //加载配置文件
        Resource classPathResource = new ClassPathResource("applicationContext.xml");
        //根据配置文件创建Bean工厂对象
        //当我们通过BeanFactory进行创建，那么所有的Bean都是延迟加载，
        // 就是当我们调用了某个getBean()方法，获取Bean对象的时候才会加载。
        BeanFactory beanFactory = new XmlBeanFactory(classPathResource);
        TeaDao teaDao = beanFactory.getBean("teaDao", TeaDao.class);
        teaDao.teaDaoMethod();
    }
}
